/******************************************************************************

	COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2010.

	This file is part of the Maxsi Library.

	Maxsi Library is free software: you can redistribute it and/or modify it
	under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or (at your
	option) any later version.

	Maxsi Library is distributed in the hope that it will be useful, but
	WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
	or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
	License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with Maxsi Library. If not, see <http://www.gnu.org/licenses/>.

	Maxsi Library
	A powerful Cross-Platform C++ General Purpose Library that allows you to
	efficiently create high-performance and reliable applications.

	MaxsiThinks.h
	An interface that allows child classes to execute a Think() function each
	time a relevant event might have occured.

******************************************************************************/

#ifndef MaxsiThinks_H
#define MaxsiThinks_H

BeginMaxsiNamespace

//=============================================================================
//	Forward declations.
//=============================================================================
class MaxsiThinks;

#ifdef Maxsi_Enable_Non_Namespaced_Macros
#define ScheduleNextThink(Type)		ScheduledNextThink(Type, __LINE__, (char*)__FUNCTION__, __FILE__ );
#endif

#define MAXSI_THINK_NONE			0x00000000	
#define MAXSI_THINK_SYSCALLBACK		0x00000001	// A completion callback has been requested from the system.
#define MAXSI_THINK_MAXSICALLBACK	0x00000002	// A completion callback has been requested from another Maxsi service.
#define MAXSI_THINK_WAIT			0x00000003	// Wait NextThinkParam miliseconds then call me. (TODO: Obsolete?)
#define MAXSI_THINK_DONT			0x00000004	// Stop thinking!
#define MAXSI_THINK_THINKAGAIN		0x00000005	// Upon the think's completion, think again.
#define MAXSI_THINK_HOLYSHI_		0x00000006	// Something awful happened and we are about to be shut down.
#define MAXSI_THINK_NO_DATA_YET		0x00000007	// No data has arrived yet, just wait.

//=============================================================================
//	Define where the MaxsiThinks interface is declared.
//=============================================================================
#undef MAXSI_INTERFACE
#define MAXSI_INTERFACE MAXSI_INTERFACE_ABSTRACT_BASECLASS

//=============================================================================
//	MaxsiThinks - A system for calling a Think() function after events.
//=============================================================================
MAXSI_CLASSLINK MaxsiThinks
{
public:
	MaxsiThinks();
	virtual ~MaxsiThinks();

public:
	virtual MaxsiError RequestThink();
	virtual MaxsiError LockThink();
	virtual MaxsiError UnlockThink();
	virtual MaxsiError Think();
	virtual MaxsiError ScheduledNextThink(int NextThinkType, int Line, char* Function, char* FileName);

//=============================================================================
//	Copy-pasteable interface MaxsiThinks from starts here.
//=============================================================================
public:
	virtual MaxsiError OnThink() MAXSI_INTERFACE;

};

EndMaxsiNamespace

#endif

